package com.guojiaming.shop.utils;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.guojiaming.shop.exception.BuildException;

/**
 * @author vivo
 */
public class GsonHelper {
    private static Gson gson;


    private GsonHelper() {
        throw new BuildException("不能使用这个类的构造器");
    }

    public static Gson create(String format) {
        if (gson == null) {
            synchronized (GsonHelper.class) {
                if (gson == null) {
                    gson = new GsonBuilder()
                            .setDateFormat(format)
                            .create();
                }
            }
        }
        return gson;
    }
}
